package com.android.powerbankpad.utils;

import com.android.powerbankpad.config.Constants;
import com.ws.universal.tools.countdown.CountDown;
import com.ws.universal.tools.countdown.TimeCount;
import com.ws.universal.tools.eventbus.BaseBusData;
import com.ws.universal.tools.eventbus.EventBusUtil;

public class TimerPlayUtils {
    private TimeCount timeCount;
    private static TimerPlayUtils sPubUiUtils;

    public static TimerPlayUtils getInstance() {
        if (sPubUiUtils == null) {
            sPubUiUtils = new TimerPlayUtils();
        }
        return sPubUiUtils;
    }

    public void init() {
        if (beautyDate == null) {
            beautyDate = new BaseBusData(Constants.playNextAD);
        }
        timeCount = new TimeCount();
        timeCount.setCountDown(new CountDown() {
            @Override
            public void onTick(long millisUntilFinished) {

            }

            @Override
            public void onTickFinish() {
                EventBusUtil.postEvent(beautyDate);
            }
        });
    }

    private BaseBusData beautyDate;

    public void playNextAD(int time) {
        timeCount.setmMillisInFuture(time * 1000);
        timeCount.start();
    }
}
